/***********************************************************************

	This file is part of KEEL-software, the Data Mining tool for regression, 
	classification, clustering, pattern mining and so on.

	Copyright (C) 2004-2010
	
	F. Herrera (herrera@decsai.ugr.es)
    L. Sanchez (luciano@uniovi.es)
    J. Alcala-Fdez (jalcala@decsai.ugr.es)
    S. Garcia (sglopez@ujaen.es)
    A. Fernandez (alberto.fernandez@ujaen.es)
    J. Luengo (julianlm@decsai.ugr.es)

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see http://www.gnu.org/licenses/
  
**********************************************************************/

/**
 * File: StatisticalF.java.
 *
 * Main frame of the statistical module
 *
 * @author Written by Joaquin Derrac (University of Granada) 29/04/2010
 * @author Modified by Joaquin Derrac (University of Granada) 1/12/2010
 * @author Modified by Joaquin Derrac (University of Granada) 7/5/2012
 * @version 1.2
 * @since JDK1.5
 */
package keel.GraphInterKeel.statistical;

import java.awt.Toolkit;
import java.io.File;
import java.io.IOException;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.table.TableColumn;
import keel.GraphInterKeel.statistical.help.HelpContent;
import keel.GraphInterKeel.statistical.tests.Contrast;
import keel.GraphInterKeel.statistical.tests.Friedman;
import keel.GraphInterKeel.statistical.tests.Multiple;
import keel.GraphInterKeel.statistical.tests.Wilcoxon;
import java.awt.FileDialog;
import java.io.FilenameFilter;

public class StatisticalF extends javax.swing.JFrame {

    protected JFrame parent = null;
    private HelpContent content = new HelpContent();
    private int testType;
    private int objective;
    private statTableModel model;
    private StatCellEditor editor;
    private statTableRenderer renderer;
    private final static int FRIEDMAN = 0;
    private final static int FRIEDMAN_ALIGNED = 1;
    private final static int QUADE = 2;
    private final static int CONTRAST = 3;
    private final static int MULTIPLE = 4;
    private final static int WILCOXON = 5;
    public final static int MINDATA = 4;
    public final static int MAXDATA = 500;
    public final static int MINALG = 2;
	public final static int MINALGF = 3;
    public final static int MAXALG = 50;
    public final static int MAXIMIZE = 1;
    public final static int MINIMIZE = 2;

    public static String lastPath;

    /**
     * Builder
     */
    public StatisticalF() {

        this.setResizable(true);

        TableColumn column;

        initComponents();

        lastPath=".";

        testType = FRIEDMAN;
        objective = MAXIMIZE;

        model = new statTableModel();

        editor = new StatCellEditor();

        renderer = new statTableRenderer();
        model.initComponents();

        dataTable.setCellEditor(editor);
        dataTable.setDefaultRenderer(Double.class, renderer);

        dataTable.setModel(model);

        for (int i = 0; i < dataTable.getColumnModel().getColumnCount(); i++) {
            column = dataTable.getColumnModel().getColumn(i);
            if (i == 0) {
                column.setPreferredWidth(80); //first column is bigger
                column.setMinWidth(80);
            } else {
                column.setPreferredWidth(75);
                column.setMinWidth(75);
            }
        }

        this.content.muestraURL(this.getClass().getResource("/help/stat/stat_help.html"));

        ExcelAdapter myAd = new ExcelAdapter(dataTable);

        //set frame icon
        this.setIconImage(Toolkit.getDefaultToolkit().getImage(StatisticalF.class.getResource("/keel/GraphInterKeel/resources/ico/logo/logo.gif")));

        //set the form visible
        this.setVisible(true);

    }//end-method

    /**
     * <p>
     * Sets parent
     * </p>
     * @param parent Frame parent
     */
    public void setParent(JFrame parent) {
        this.parent = parent;
    }//end-method

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        divider = new javax.swing.JSplitPane();
        mainPanel = new javax.swing.JPanel();
        optionsPanel = new javax.swing.JPanel();
        checkIman = new javax.swing.JCheckBox();
        checkBonferroni = new javax.swing.JCheckBox();
        checkHolm = new javax.swing.JCheckBox();
        checkHochberg = new javax.swing.JCheckBox();
        checkFinner = new javax.swing.JCheckBox();
        checkRom = new javax.swing.JCheckBox();
        checkHolland = new javax.swing.JCheckBox();
        checkHommel = new javax.swing.JCheckBox();
        checkLi = new javax.swing.JCheckBox();
        checkNemenyi = new javax.swing.JCheckBox();
        checkShaffer = new javax.swing.JCheckBox();
        checkBergman = new javax.swing.JCheckBox();
        radioPanel = new javax.swing.JPanel();
        radioBFriedman = new javax.swing.JRadioButton();
        radioBAligned = new javax.swing.JRadioButton();
        radioBContrast = new javax.swing.JRadioButton();
        radioBQuade = new javax.swing.JRadioButton();
        radioBMultiple = new javax.swing.JRadioButton();
        radioBWilcoxon = new javax.swing.JRadioButton();
        buttonPanel = new javax.swing.JPanel();
        loadButton = new javax.swing.JButton();
        clearButton = new javax.swing.JButton();
        analysisButton = new javax.swing.JButton();
        exportButton = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        dimensionsButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        methodsField = new javax.swing.JTextField();
        datasetsField = new javax.swing.JTextField();
        scrollTable = new javax.swing.JScrollPane();
        dataTable = new javax.swing.JTable();
        measurePanel = new javax.swing.JPanel();
        radioBMaximize = new javax.swing.JRadioButton();
        radioBMinimize = new javax.swing.JRadioButton();
        auxHelpPanel = new javax.swing.JPanel();
        helpPanel = new javax.swing.JTabbedPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(keel.GraphInterKeel.datacf.DataCFApp.class).getContext().getResourceMap(StatisticalF.class);
        setTitle(resourceMap.getString("MainForm.title")); // NOI18N
        setName("Form"); // NOI18N
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        divider.setDividerLocation(525);
        divider.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
        divider.setName("divider"); // NOI18N

        mainPanel.setMinimumSize(new java.awt.Dimension(800, 300));
        mainPanel.setName("mainPanel"); // NOI18N
        mainPanel.setPreferredSize(new java.awt.Dimension(800, 525));

        optionsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("optionsPanel.border.title"))); // NOI18N
        optionsPanel.setToolTipText(resourceMap.getString("optionsPanel.toolTipText")); // NOI18N
        optionsPanel.setName("optionsPanel"); // NOI18N

        checkIman.setText(resourceMap.getString("checkIman.text")); // NOI18N
        checkIman.setName("checkIman"); // NOI18N

        checkBonferroni.setText(resourceMap.getString("checkBonferroni.text")); // NOI18N
        checkBonferroni.setName("checkBonferroni"); // NOI18N

        checkHolm.setText(resourceMap.getString("checkHolm.text")); // NOI18N
        checkHolm.setName("checkHolm"); // NOI18N

        checkHochberg.setText(resourceMap.getString("checkHochberg.text")); // NOI18N
        checkHochberg.setName("checkHochberg"); // NOI18N

        checkFinner.setText(resourceMap.getString("checkFinner.text")); // NOI18N
        checkFinner.setName("checkFinner"); // NOI18N

        checkRom.setText(resourceMap.getString("checkRom.text")); // NOI18N
        checkRom.setName("checkRom"); // NOI18N

        checkHolland.setText(resourceMap.getString("checkHolland.text")); // NOI18N
        checkHolland.setName("checkHolland"); // NOI18N

        checkHommel.setText(resourceMap.getString("checkHommel.text")); // NOI18N
        checkHommel.setName("checkHommel"); // NOI18N

        checkLi.setText(resourceMap.getString("checkLi.text")); // NOI18N
        checkLi.setName("checkLi"); // NOI18N

        checkNemenyi.setText(resourceMap.getString("checkNemenyi.text")); // NOI18N
        checkNemenyi.setEnabled(false);
        checkNemenyi.setName("checkNemenyi"); // NOI18N

        checkShaffer.setText(resourceMap.getString("checkShaffer.text")); // NOI18N
        checkShaffer.setEnabled(false);
        checkShaffer.setName("checkShaffer"); // NOI18N

        checkBergman.setText(resourceMap.getString("checkBergman.text")); // NOI18N
        checkBergman.setEnabled(false);
        checkBergman.setName("checkBergman"); // NOI18N

        javax.swing.GroupLayout optionsPanelLayout = new javax.swing.GroupLayout(optionsPanel);
        optionsPanel.setLayout(optionsPanelLayout);
        optionsPanelLayout.setHorizontalGroup(
            optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(optionsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(checkBonferroni, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(checkIman, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(optionsPanelLayout.createSequentialGroup()
                        .addComponent(checkHolm, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(56, 56, 56))
                    .addGroup(optionsPanelLayout.createSequentialGroup()
                        .addComponent(checkHochberg, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(34, 34, 34)))
                .addGroup(optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(checkRom)
                    .addComponent(checkFinner)
                    .addComponent(checkHolland, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(checkHommel))
                .addGap(35, 35, 35)
                .addGroup(optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(checkLi)
                    .addComponent(checkNemenyi, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(checkShaffer)
                    .addComponent(checkBergman))
                .addGap(13, 13, 13))
        );
        optionsPanelLayout.setVerticalGroup(
            optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(optionsPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(optionsPanelLayout.createSequentialGroup()
                        .addComponent(checkHommel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(checkHolland)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(checkRom)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(checkFinner))
                    .addGroup(optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(optionsPanelLayout.createSequentialGroup()
                            .addComponent(checkLi)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(checkNemenyi)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(checkShaffer)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(checkBergman))
                        .addGroup(optionsPanelLayout.createSequentialGroup()
                            .addComponent(checkIman)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(checkBonferroni)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(checkHolm)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(checkHochberg)))))
        );

        radioPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("radioPanel.border.title"))); // NOI18N
        radioPanel.setToolTipText(resourceMap.getString("radioPanel.toolTipText")); // NOI18N
        radioPanel.setName("radioPanel"); // NOI18N

        buttonGroup1.add(radioBFriedman);
        radioBFriedman.setSelected(true);
        radioBFriedman.setText(resourceMap.getString("radioBFriedman.text")); // NOI18N
        radioBFriedman.setName("radioBFriedman"); // NOI18N
        radioBFriedman.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioBFriedmanActionPerformed(evt);
            }
        });

        buttonGroup1.add(radioBAligned);
        radioBAligned.setText(resourceMap.getString("radioBAligned.text")); // NOI18N
        radioBAligned.setName("radioBAligned"); // NOI18N
        radioBAligned.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioBAlignedActionPerformed(evt);
            }
        });

        buttonGroup1.add(radioBContrast);
        radioBContrast.setText(resourceMap.getString("radioBContrast.text")); // NOI18N
        radioBContrast.setName("radioBContrast"); // NOI18N
        radioBContrast.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioBContrastActionPerformed(evt);
            }
        });

        buttonGroup1.add(radioBQuade);
        radioBQuade.setText(resourceMap.getString("radioBQuade.text")); // NOI18N
        radioBQuade.setName("radioBQuade"); // NOI18N
        radioBQuade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioBQuadeActionPerformed(evt);
            }
        });

        buttonGroup1.add(radioBMultiple);
        radioBMultiple.setText(resourceMap.getString("radioBMultiple.text")); // NOI18N
        radioBMultiple.setName("radioBMultiple"); // NOI18N
        radioBMultiple.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioBMultipleActionPerformed(evt);
            }
        });

        buttonGroup1.add(radioBWilcoxon);
        radioBWilcoxon.setText(resourceMap.getString("radioBWilcoxon.text")); // NOI18N
        radioBWilcoxon.setName("radioBWilcoxon"); // NOI18N
        radioBWilcoxon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioBWilcoxonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout radioPanelLayout = new javax.swing.GroupLayout(radioPanel);
        radioPanel.setLayout(radioPanelLayout);
        radioPanelLayout.setHorizontalGroup(
            radioPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, radioPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(radioPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(radioBQuade)
                    .addComponent(radioBFriedman)
                    .addComponent(radioBAligned))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(radioPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, radioPanelLayout.createSequentialGroup()
                        .addComponent(radioBContrast)
                        .addGap(50, 50, 50))
                    .addGroup(radioPanelLayout.createSequentialGroup()
                        .addGroup(radioPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(radioBMultiple)
                            .addComponent(radioBWilcoxon))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );
        radioPanelLayout.setVerticalGroup(
            radioPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(radioPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(radioPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(radioBFriedman)
                    .addComponent(radioBMultiple))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(radioPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(radioBQuade)
                    .addComponent(radioBContrast))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(radioPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(radioBAligned)
                    .addComponent(radioBWilcoxon)))
        );

        buttonPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        buttonPanel.setName("buttonPanel"); // NOI18N

        loadButton.setText(resourceMap.getString("loadButton.text")); // NOI18N
        loadButton.setName("loadButton"); // NOI18N
        loadButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loadButtonActionPerformed(evt);
            }
        });

        clearButton.setText(resourceMap.getString("clearButton.text")); // NOI18N
        clearButton.setName("clearButton"); // NOI18N
        clearButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clearButtonActionPerformed(evt);
            }
        });

        analysisButton.setText(resourceMap.getString("analysisButton.text")); // NOI18N
        analysisButton.setName("analysisButton"); // NOI18N
        analysisButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                analysisButtonActionPerformed(evt);
            }
        });

        exportButton.setText(resourceMap.getString("exportButton.text")); // NOI18N
        exportButton.setName("exportButton"); // NOI18N
        exportButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exportButtonActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel1.setName("jPanel1"); // NOI18N

        dimensionsButton.setText(resourceMap.getString("dimensionsButton.text")); // NOI18N
        dimensionsButton.setName("dimensionsButton"); // NOI18N
        dimensionsButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dimensionsButtonActionPerformed(evt);
            }
        });

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        methodsField.setText(resourceMap.getString("methodsField.text")); // NOI18N
        methodsField.setName("methodsField"); // NOI18N

        datasetsField.setText(resourceMap.getString("datasetsField.text")); // NOI18N
        datasetsField.setName("datasetsField"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(dimensionsButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 67, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(methodsField, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(datasetsField, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(methodsField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(datasetsField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2)))
                    .addComponent(dimensionsButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        javax.swing.GroupLayout buttonPanelLayout = new javax.swing.GroupLayout(buttonPanel);
        buttonPanel.setLayout(buttonPanelLayout);
        buttonPanelLayout.setHorizontalGroup(
            buttonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(buttonPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(buttonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(buttonPanelLayout.createSequentialGroup()
                        .addComponent(loadButton, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(exportButton, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(clearButton))
                    .addGroup(buttonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(analysisButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        buttonPanelLayout.setVerticalGroup(
            buttonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(buttonPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(buttonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(clearButton, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(exportButton, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(loadButton, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(analysisButton, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE)
                .addContainerGap())
        );

        scrollTable.setName("scrollTable"); // NOI18N

        dataTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        dataTable.setName("dataTable"); // NOI18N
        dataTable.setRowSelectionAllowed(false);
        dataTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        dataTable.getTableHeader().setReorderingAllowed(false);
        scrollTable.setViewportView(dataTable);

        measurePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("measurePanel.border.title"))); // NOI18N
        measurePanel.setName("measurePanel"); // NOI18N

        buttonGroup2.add(radioBMaximize);
        radioBMaximize.setSelected(true);
        radioBMaximize.setText(resourceMap.getString("radioBMaximize.text")); // NOI18N
        radioBMaximize.setName("radioBMaximize"); // NOI18N
        radioBMaximize.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioBMaximizeActionPerformed(evt);
            }
        });

        buttonGroup2.add(radioBMinimize);
        radioBMinimize.setText(resourceMap.getString("radioBMinimize.text")); // NOI18N
        radioBMinimize.setName("radioBMinimize"); // NOI18N
        radioBMinimize.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioBMinimizeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout measurePanelLayout = new javax.swing.GroupLayout(measurePanel);
        measurePanel.setLayout(measurePanelLayout);
        measurePanelLayout.setHorizontalGroup(
            measurePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, measurePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(radioBMaximize)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(radioBMinimize)
                .addGap(63, 63, 63))
        );
        measurePanelLayout.setVerticalGroup(
            measurePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(measurePanelLayout.createSequentialGroup()
                .addGroup(measurePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(radioBMinimize)
                    .addComponent(radioBMaximize))
                .addContainerGap(7, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(radioPanel, 0, 0, Short.MAX_VALUE)
                    .addComponent(optionsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(measurePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(buttonPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(scrollTable, javax.swing.GroupLayout.DEFAULT_SIZE, 401, Short.MAX_VALUE)
                .addContainerGap())
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(scrollTable, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
                        .addComponent(radioPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(optionsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(measurePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(19, Short.MAX_VALUE))
        );

        divider.setTopComponent(mainPanel);

        auxHelpPanel.setMinimumSize(new java.awt.Dimension(800, 25));
        auxHelpPanel.setName("auxHelpPanel"); // NOI18N
        auxHelpPanel.setPreferredSize(new java.awt.Dimension(800, 75));

        helpPanel.setName("helpTabbedPane"); // NOI18N
        helpPanel.addTab("User Manual", content);

        javax.swing.GroupLayout auxHelpPanelLayout = new javax.swing.GroupLayout(auxHelpPanel);
        auxHelpPanel.setLayout(auxHelpPanelLayout);
        auxHelpPanelLayout.setHorizontalGroup(
            auxHelpPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(helpPanel)
        );
        auxHelpPanelLayout.setVerticalGroup(
            auxHelpPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(auxHelpPanelLayout.createSequentialGroup()
                .addComponent(helpPanel)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        divider.setRightComponent(auxHelpPanel);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(divider, javax.swing.GroupLayout.PREFERRED_SIZE, 800, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(divider, javax.swing.GroupLayout.DEFAULT_SIZE, 726, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        if (this.parent != null) {
            this.parent.setVisible(true);
        }
    }//GEN-LAST:event_formWindowClosing

    private void radioBFriedmanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioBFriedmanActionPerformed
        testType = FRIEDMAN;

        setOneAllChecks();
        unsetMultipleChecks();

        radioBMaximize.setEnabled(true);
        radioBMinimize.setEnabled(true);

    }//GEN-LAST:event_radioBFriedmanActionPerformed

    private void radioBQuadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioBQuadeActionPerformed
        testType = QUADE;

        setOneAllChecks();
        unsetMultipleChecks();

        radioBMaximize.setEnabled(true);
        radioBMinimize.setEnabled(true);
    }//GEN-LAST:event_radioBQuadeActionPerformed

    private void radioBAlignedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioBAlignedActionPerformed
        testType = FRIEDMAN_ALIGNED;

        setOneAllChecks();
        unsetMultipleChecks();

        radioBMaximize.setEnabled(true);
        radioBMinimize.setEnabled(true);
    }//GEN-LAST:event_radioBAlignedActionPerformed

    private void radioBMultipleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioBMultipleActionPerformed
        testType = MULTIPLE;

        unsetOneAllChecks();
        setMultipleChecks();

        radioBMaximize.setEnabled(true);
        radioBMinimize.setEnabled(true);
    }//GEN-LAST:event_radioBMultipleActionPerformed

    private void radioBContrastActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioBContrastActionPerformed
        testType = CONTRAST;

        unsetOneAllChecks();
        unsetMultipleChecks();

        radioBMaximize.setEnabled(false);
        radioBMinimize.setEnabled(false);
    }//GEN-LAST:event_radioBContrastActionPerformed

    private void dimensionsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dimensionsButtonActionPerformed

        int newData;
        int newMethod;
        int code;

        int salvar = JOptionPane.YES_OPTION;

        salvar = JOptionPane.showConfirmDialog(this,
                "This will erase all data. Are you sure?", "Set dimensions",
                JOptionPane.YES_NO_OPTION);

        if (salvar == JOptionPane.YES_OPTION) {
            try {
                newData = Integer.parseInt(datasetsField.getText());
                newMethod = Integer.parseInt(methodsField.getText());

            } catch (NumberFormatException e) {
                newData = 0;
                newMethod = 0;
            }

            code = adequateDimensions(newMethod, newData);

            switch (code) {
                case 0:
                    model.resizeTable(newData, newMethod);
                    break;
                case 1:
                    JOptionPane.showMessageDialog(this, "Error setting dimensions:\n" +
                            "The number of datsets must be between " + MINDATA + " and " + MAXDATA + " .", "Error", JOptionPane.ERROR_MESSAGE);
                    break;
                case 2:
                    JOptionPane.showMessageDialog(this, "Error setting dimensions:\n" +
                            "The number of algorithms must be between " + MINALG + " and " + MAXALG + " .", "Error", JOptionPane.ERROR_MESSAGE);
                    break;
            }

            scrollTable.repaint();
        }


    }//GEN-LAST:event_dimensionsButtonActionPerformed

    private void clearButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearButtonActionPerformed

        int salvar = JOptionPane.YES_OPTION;

        salvar = JOptionPane.showConfirmDialog(this,
                "This will erase all data. Are you sure?", "Clear data",
                JOptionPane.YES_NO_OPTION);
        if (salvar == JOptionPane.YES_OPTION) {
            model.resetData();
        }

}//GEN-LAST:event_clearButtonActionPerformed

    private void exportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportButtonActionPerformed

        File saveFile = null;

        String contents;
        String path;

//        JFileChooser chooser = new JFileChooser(lastPath);
//
//        chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
//        chooser.setDialogTitle("Select a name to export the file");
//
//        CSVFileFilter filter = new CSVFileFilter();
//        filter.addExtension("csv");
//        filter.setFilterName("CSV Files");
//        chooser.setFileFilter(filter);
//        chooser.setAcceptAllFileFilterUsed(true);
//
//        int returnVal = chooser.showSaveDialog(this);
//        if (returnVal == JFileChooser.APPROVE_OPTION) {
//            saveFile = chooser.getSelectedFile();
//            lastPath=chooser.getSelectedFile().getParent();
//        } else {
//            return;
//        }
        
        FileDialog chooser2 = new FileDialog(this,lastPath,FileDialog.SAVE);
        chooser2.setTitle("Select a name to export the file");
        chooser2.setFilenameFilter(new FilenameFilter() {
            @Override public boolean accept(File dir, String name) {
                return name.endsWith(".csv");
            }
        });
        chooser2.setMultipleMode(false);
        chooser2.setVisible(true);
        
        if(chooser2.getFile() != null){
            saveFile = new File(chooser2.getDirectory()+chooser2.getFile());
            lastPath=saveFile.getParent();
        }else return;

        try {
            path = saveFile.getCanonicalPath();
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(this, "Error exporting data:\n" + ex.getLocalizedMessage(), "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }

        if (!path.endsWith(".csv")) {
            path += ".csv";
        }

        contents = model.generateCSVOutput();

        Files.writeFile(path, contents);

        JOptionPane.showMessageDialog(this, "Data succesfully exported to " + path + " file.", "Export data", JOptionPane.INFORMATION_MESSAGE);
}//GEN-LAST:event_exportButtonActionPerformed

    private void loadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadButtonActionPerformed

        File loadFile = null;
        int errorCode;

        String contents;
        String path;

        FileDialog chooser2 = new FileDialog(this,lastPath,FileDialog.LOAD);
        chooser2.setTitle("Select a CSV file to load");
        chooser2.setFilenameFilter(new FilenameFilter() {
            @Override public boolean accept(File dir, String name) {
                return name.endsWith(".csv");
            }
        });
        chooser2.setMultipleMode(false);
        chooser2.setVisible(true);
        
        if(chooser2.getFile() != null){
            loadFile = new File(chooser2.getDirectory()+chooser2.getFile());
            lastPath=loadFile.getParent();
        }else return;
        
        /**
        JFileChooser chooser = new JFileChooser(lastPath);

        chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        chooser.setDialogTitle("Select a CSV file to load");

        CSVFileFilter filter = new CSVFileFilter();
        filter.addExtension("csv");
        filter.setFilterName("CSV Files");
        chooser.setFileFilter(filter);

        chooser.setAcceptAllFileFilterUsed(true);

        int returnVal = chooser.showOpenDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            loadFile = chooser.getSelectedFile();
            lastPath=chooser.getSelectedFile().getParent();
        } else {
            return;
        }*/

        try {
            path = loadFile.getCanonicalPath();
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(this, "Error loading data:\n" + ex.getLocalizedMessage(), "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }

        if (!path.endsWith(".csv")) {
            JOptionPane.showMessageDialog(this, "Error loading data:\n "+path+" is not a .csv file" , "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }

        contents = Files.readFile(path);

        errorCode = model.loadCSVData(contents);

        switch (errorCode) {

            case 0:
                JOptionPane.showMessageDialog(this, "Data succesfully loaded.", "Load data", JOptionPane.INFORMATION_MESSAGE);
                break;

            case 1:
                JOptionPane.showMessageDialog(this, "Error loading data:\n" + "Data is not in CSV format", "Error", JOptionPane.ERROR_MESSAGE);
                break;

            case 2:
                JOptionPane.showMessageDialog(this, "Error loading data:\n" + "Data must contain results of " + MINALG + " algorithms, at least ", "Error", JOptionPane.ERROR_MESSAGE);
                break;

            case 3:
                JOptionPane.showMessageDialog(this, "Error loading data:\n" + "Data must contain results in " + MINDATA + " data sets, at least ", "Error", JOptionPane.ERROR_MESSAGE);
                break;

            case 4:
                JOptionPane.showMessageDialog(this, "Error loading data:\n" + "Data must contain results of less than " + (MAXALG + 1) + " algorithms.", "Error", JOptionPane.ERROR_MESSAGE);
                break;

            case 5:
                JOptionPane.showMessageDialog(this, "Error loading data:\n" + "Data must contain results of less than " + (MAXDATA + 1) + " data sets.", "Error", JOptionPane.ERROR_MESSAGE);
                break;
        }

        methodsField.setText("" + (model.getColumnCount() - 1));
        datasetsField.setText("" + (model.getRowCount()));

    }//GEN-LAST:event_loadButtonActionPerformed

    private void analysisButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_analysisButtonActionPerformed

        File saveFile = null;

        String path;

        JFileChooser chooser = new JFileChooser(lastPath);

        chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        chooser.setDialogTitle("Select a name for the resuls file");

        CSVFileFilter filter = new CSVFileFilter();
        filter.addExtension("tex");
        filter.setFilterName("TeX Files");
        chooser.setFileFilter(filter);
        chooser.setAcceptAllFileFilterUsed(true);
        
        int returnVal = chooser.showSaveDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            saveFile = chooser.getSelectedFile();
            lastPath = chooser.getSelectedFile().getParent();

        } else {
            return;
        }

        try {
            path = saveFile.getCanonicalPath();
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(this, "Error generating results file.", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }

        if (!path.endsWith(".tex")) {
            path += ".tex";
        }

        //Prepare configuration

        Configuration.setPath(path);
        Configuration.setNAlgorithms(model.getColumnCount() - 1);
        Configuration.setNDatasets(model.getRowCount());
        Configuration.setObjective(objective);

        Configuration.setIman(checkIman.isSelected());
        Configuration.setBonferroni(checkBonferroni.isSelected());
        Configuration.setHolm(checkHolm.isSelected());
        Configuration.setHochberg(checkHochberg.isSelected());
        Configuration.setHommel(checkHommel.isSelected());
        Configuration.setHolland(checkHolland.isSelected());
        Configuration.setRom(checkRom.isSelected());
        Configuration.setFinner(checkFinner.isSelected());
        Configuration.setLi(checkLi.isSelected());
        Configuration.setNemenyi(checkNemenyi.isSelected());
        Configuration.setShaffer(checkShaffer.isSelected());
        Configuration.setBergman(checkBergman.isSelected());

        //Launch tests
        String algorithmNames[] = new String[model.getColumnCount() - 1];

        for (int i = 0; i < algorithmNames.length; i++) {
            algorithmNames[i] = model.getColumnName(i + 1);
            algorithmNames[i] = formatLatex(algorithmNames[i]);
        }

        double data[][] = new double[algorithmNames.length][model.getRowCount()];

        for (int i = 0; i < algorithmNames.length; i++) {
            for (int j = 0; j < model.getRowCount(); j++) {
                data[i][j] = (Double) model.getValueAt(j, i + 1);
            }
        }

        String location;

        location="Results file in .tex format can be found in "+path;

        switch (testType) {

            case FRIEDMAN:
				if(algorithmNames.length<MINALGF){
					JOptionPane.showMessageDialog(this, "Friedman test must include at least "+MINALGF+" algorithms.", "Error", JOptionPane.ERROR_MESSAGE);
				}else{
					Friedman.doFriedman(data, algorithmNames);
					JOptionPane.showMessageDialog(this, "Friedman test performed succesfully.\n"+location, "Analysis performed", JOptionPane.INFORMATION_MESSAGE);
				}
                break;

            case FRIEDMAN_ALIGNED:
				if(algorithmNames.length<MINALGF){
					JOptionPane.showMessageDialog(this, "Friedman Aligned test must include at least "+MINALGF+" algorithms.", "Error", JOptionPane.ERROR_MESSAGE);
				}else{
					Friedman.doFriedmanAligned(data, algorithmNames);
					JOptionPane.showMessageDialog(this, "Friedman Aligned test performed succesfully.\n"+location, "Analysis performed", JOptionPane.INFORMATION_MESSAGE);
				}
                break;

            case QUADE:
				if(algorithmNames.length<MINALGF){
					JOptionPane.showMessageDialog(this, "Quade test must include at least "+MINALGF+" algorithms.", "Error", JOptionPane.ERROR_MESSAGE);
				}else{
					Friedman.doQuade(data, algorithmNames);
					JOptionPane.showMessageDialog(this, "Quade test performed succesfully.\n"+location, "Analysis performed", JOptionPane.INFORMATION_MESSAGE);
				}
                break;

            case MULTIPLE:
				if(algorithmNames.length<MINALGF){
					JOptionPane.showMessageDialog(this, "Friedman NxN test must include at least "+MINALGF+" algorithms.", "Error", JOptionPane.ERROR_MESSAGE);
					break;
				}else{
					Multiple.doMultiple(data, algorithmNames);
					JOptionPane.showMessageDialog(this, "Friedman NxN test performed succesfully.\n"+location, "Analysis performed", JOptionPane.INFORMATION_MESSAGE);
                }
				break;

            case CONTRAST:
                Contrast.doContrast(data, algorithmNames);
                JOptionPane.showMessageDialog(this, "Contrast estimation performed succesfully.\n"+location, "Analysis performed", JOptionPane.INFORMATION_MESSAGE);
                break;

            case WILCOXON:
                Wilcoxon.doWilcoxon(data, algorithmNames);
                JOptionPane.showMessageDialog(this, "Wilcoxon test performed succesfully.\n"+location, "Analysis performed", JOptionPane.INFORMATION_MESSAGE);
                break;
        }


}//GEN-LAST:event_analysisButtonActionPerformed

    private void radioBMaximizeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioBMaximizeActionPerformed
        objective = MAXIMIZE;
    }//GEN-LAST:event_radioBMaximizeActionPerformed

    private void radioBMinimizeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioBMinimizeActionPerformed
        objective = MINIMIZE;
    }//GEN-LAST:event_radioBMinimizeActionPerformed

    private void radioBWilcoxonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioBWilcoxonActionPerformed
        testType = WILCOXON;

        unsetOneAllChecks();
        unsetMultipleChecks();

        radioBMaximize.setEnabled(true);
        radioBMinimize.setEnabled(true);
}//GEN-LAST:event_radioBWilcoxonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new StatisticalF().setVisible(true);
            }
        });
    }//end-method

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton analysisButton;
    private javax.swing.JPanel auxHelpPanel;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JPanel buttonPanel;
    private javax.swing.JCheckBox checkBergman;
    private javax.swing.JCheckBox checkBonferroni;
    private javax.swing.JCheckBox checkFinner;
    private javax.swing.JCheckBox checkHochberg;
    private javax.swing.JCheckBox checkHolland;
    private javax.swing.JCheckBox checkHolm;
    private javax.swing.JCheckBox checkHommel;
    private javax.swing.JCheckBox checkIman;
    private javax.swing.JCheckBox checkLi;
    private javax.swing.JCheckBox checkNemenyi;
    private javax.swing.JCheckBox checkRom;
    private javax.swing.JCheckBox checkShaffer;
    private javax.swing.JButton clearButton;
    private javax.swing.JTable dataTable;
    private javax.swing.JTextField datasetsField;
    private javax.swing.JButton dimensionsButton;
    private javax.swing.JSplitPane divider;
    private javax.swing.JButton exportButton;
    private javax.swing.JTabbedPane helpPanel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JButton loadButton;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JPanel measurePanel;
    private javax.swing.JTextField methodsField;
    private javax.swing.JPanel optionsPanel;
    private javax.swing.JRadioButton radioBAligned;
    private javax.swing.JRadioButton radioBContrast;
    private javax.swing.JRadioButton radioBFriedman;
    private javax.swing.JRadioButton radioBMaximize;
    private javax.swing.JRadioButton radioBMinimize;
    private javax.swing.JRadioButton radioBMultiple;
    private javax.swing.JRadioButton radioBQuade;
    private javax.swing.JRadioButton radioBWilcoxon;
    private javax.swing.JPanel radioPanel;
    private javax.swing.JScrollPane scrollTable;
    // End of variables declaration//GEN-END:variables

    /**
     * Enables all checks for one vs all tests
     */
    private void setOneAllChecks() {

        checkIman.setEnabled(true);
        checkBonferroni.setEnabled(true);
        checkHolm.setEnabled(true);
        checkHochberg.setEnabled(true);
        checkHommel.setEnabled(true);
        checkHolland.setEnabled(true);
        checkRom.setEnabled(true);
        checkFinner.setEnabled(true);
        checkLi.setEnabled(true);

    }//end-method

    /**
     * Disables all checks for one vs all tests
     */
    private void unsetOneAllChecks() {

        checkIman.setEnabled(false);
        checkBonferroni.setEnabled(false);
        checkHolm.setEnabled(false);
        checkHochberg.setEnabled(false);
        checkHommel.setEnabled(false);
        checkHolland.setEnabled(false);
        checkRom.setEnabled(false);
        checkFinner.setEnabled(false);
        checkLi.setEnabled(false);

    }//end-method

    /**
     * Enables all checks for multiple tests
     */
    private void setMultipleChecks() {

        checkNemenyi.setEnabled(true);
        checkShaffer.setEnabled(true);
        checkBergman.setEnabled(true);

        checkIman.setEnabled(true);
        checkHolm.setEnabled(true);
    }//end-method

    /**
     * Disables all checks for multiple tests
     */
    private void unsetMultipleChecks() {

        checkNemenyi.setEnabled(false);
        checkShaffer.setEnabled(false);
        checkBergman.setEnabled(false);

    }//end-method

    /**
     * Test if the dimensions selected are right
     *
     * @param cols Columns desired
     * @param rows Rows desired
     *
     * @return 0 if the dimensions selected are right, > 0 if not
     */
    private int adequateDimensions(int cols, int rows) {

        if ((cols >= MINALG) && (cols <= MAXALG)) {
            if ((rows >= MINDATA) && (rows <= MAXDATA)) {
                return 0;
            } else {
                return 1;
            }
        } else {
            return 2;
        }

    }//end-method

    /**
     * replaces characters non adequate for LaTeX formatting
     *
     * @param text String to scan
     *
     * @return A string replaced
     */
    private String formatLatex(String text){

        String output=text.replaceAll("_","-");

        return output;
    }//end-method

}//end-class
